package io.jft.doll.ui.room

import android.os.Bundle
import com.g.base.ui.BaseFragment
import com.ogaclejapan.smarttablayout.utils.v4.FragmentPagerItem
import com.ogaclejapan.smarttablayout.utils.v4.FragmentPagerItemAdapter
import com.ogaclejapan.smarttablayout.utils.v4.FragmentPagerItems
import io.jft.doll.R
import io.jft.doll.databinding.FragmentRoomViewpagerBinding
import io.jft.doll.ui.room.detailFragment.RoomImageFragment
import io.jft.doll.ui.room.detailFragment.RoomRankFragment
import io.jft.doll.ui.room.detailFragment.RoomRecentFragment

/**
 * Created by G on 2017/12/20 0020.
 */

class RoomDetailFragment : BaseFragment<FragmentRoomViewpagerBinding>() {
    override fun setContentView(): Int = R.layout.fragment_room_viewpager
    override fun onActivityCreated(savedInstanceState: Bundle?) {
        super.onActivityCreated(savedInstanceState)
        baseRootView.background = null
        val viewpager = contentView.viewpager
        val smartTabLayout = contentView.smartTabLayout
        viewpager.adapter = FragmentPagerItemAdapter(childFragmentManager,
                FragmentPagerItems.with(activity).apply {
                    add(FragmentPagerItem.of("娃娃详情", RoomImageFragment::class.java))
                    add(FragmentPagerItem.of("最近抓中记录", RoomRecentFragment::class.java))
                    add(FragmentPagerItem.of("抓娃娃达人", RoomRankFragment::class.java))
                }.create())

        smartTabLayout.setViewPager(viewpager)
        viewpager.offscreenPageLimit = 3
        showContentView()
    }
}